package com.friends.design.mode.observer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 *
 * @Author Zhao Tianhao
 * @Description 事件发送
 * @Date 2024/10/9 15:29
 */
@Slf4j
@Component
public class XEventPublisher {

	@Resource
	private ApplicationEventPublisher applicationEventPublisher;

	public void publish(String message) {
		XEvent xEvent = new XEvent(this, message);
		log.info("发布事件:{}", xEvent.getMessage());
		applicationEventPublisher.publishEvent(xEvent);
	}

	public void publishEventB(String message) {
		XEventB xEventB = new XEventB(this, message);
		log.info("发布事件B:{}", xEventB.getMessage());
		applicationEventPublisher.publishEvent(xEventB);
	}
}
